import api, ui
from controlTypes.role import Role
def activateFromCurrentWindow ():
    focus = api.getFocusObject ()
    for child in focus.recursiveDescendants:
        if child.role == Role.DOCUMENT:
            child.setFocus ()
            return
    obj = api.getForegroundObject ()
    for child in obj.recursiveDescendants:
        if focus == child: continue
        if child.role == Role.DOCUMENT:
            child.setFocus ()
            return
    ui.message ('找不到网页对象')